package vsy.buzzwordbingo.client;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

import java.awt.Dimension;
import javax.swing.JTextField;
import java.awt.Frame;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JSplitPane;
import java.awt.Point;
import java.awt.Rectangle;

public class TitleWindow {
	
	private JPanel jPanel = null;  
	private JFrame TitleWindow = null;  
	private JPanel jPanel1 = null;
	private JButton Login = null;
	private JTextField fieldName = null;
	private JLabel nameLabel = null;
	
	/**
	 * This method initializes TitleWindow	
	 * 	
	 * @return javax.swing.JFrame	
	 */
	public JFrame getTitleWindow() {
		if (TitleWindow == null) {
			TitleWindow = new JFrame();
			TitleWindow.setSize(new Dimension(800, 640));
			TitleWindow.setLocationRelativeTo(null);
			TitleWindow.setResizable(false);
			TitleWindow.setContentPane(getJPanel1());
			TitleWindow.add(new JLabel("Label"));
		    TitleWindow.add(new JButton("Button"));
			TitleWindow.setTitle("Buzzword Bingo");
			TitleWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			TitleWindow.addWindowListener(new java.awt.event.WindowAdapter() {
				public void windowClosing(java.awt.event.WindowEvent e) {
					System.out.println("Client closed"); // TODO Auto-generated Event stub windowClosing()
					System.exit(0);
				}
			});
		}
		return TitleWindow;
	}
	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			nameLabel = new JLabel();
			nameLabel.setBounds(new Rectangle(135, 445, 96, 18));
			nameLabel.setText("Name:");
			jPanel1 = new BackGroundPane("src/main/images/buzzwordbingo_title_bg.jpg");
			jPanel1.setLayout(null);
			jPanel1.add(getLogin(), null);
			jPanel1.add(getFieldName(), null);
			jPanel1.add(nameLabel, null);
		}
		return jPanel1;
	}
	/**
	 * This method initializes Login	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getLogin() {
		if (Login == null) {
			Login = new JButton();
			Login.setLocation(283, 463);
			Login.setText("Login");
			Login.setSize(new Dimension(74, 16));
			Login.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					TitleWindow.setVisible(false);
					ServerList serverListWindow = new ServerList();
					serverListWindow.initialize();
					serverListWindow.setVisible(true);
					}
			});
		}
		return Login;
	}
	/**
	 * This method initializes fieldName	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getFieldName() {
		if (fieldName == null) {
			fieldName = new JTextField();
			fieldName.setBounds(new Rectangle(135, 463, 138, 17));
		}
		return fieldName;
	}

}
